//   输入: [
// ​         { key: 'name', value: 'zhangsan' },
// ​         { key: 'age', value: 18 },
// ​         { key: 'sex', value: 'male' },
// ​         { key: 'weight', value: 100 }
//   ]

//   返回: { name: 'zhangsan', age: 18, sex: 'male', weight: 100 }

function arr2obj (arr) {
    const obj = {};
    for (const item of arr) {
        obj[item.key] = item.value;
    }
    return obj;
}

const arr = [
    { key: 'name', value: 'zhangsan' },
    { key: 'age', value: 18 },
    { key: 'sex', value: 'male' },
    { key: 'weight', value: 100 },
];

const numArr = [
    [1, 2, 3],
    [3, 4],
];

console.log( arr2obj(arr) ); // { name: 'zhangsan', age: 18, sex: 'male', weight: 100 }